package com.sky.config;

import com.sky.properties.AliOssProperties;
import com.sky.utils.AliOssUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.web.servlet.ConditionalOnMissingFilterBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class OssComfigration {

    @Bean( name = "aliOssUtil")
    @ConditionalOnMissingBean //确保为单例类
    //AliyunOSSOProperties类对象放入了IOC容器中，创建AliyunOSSOperator对象时，会自动传入AliyunOSSProperties对象
    public AliOssUtil aliyunOSSOperator(@Autowired AliOssProperties aliOssProperties){ //@Autowired注解可以省略
        return new AliOssUtil(aliOssProperties);
    }
}
